{*
 * This file is part of the Agora distribution. 
 * Detailed copyright and licensing information can be found
 * in the gpl-3.0.txt file which should be included in the distribution.
 * 
 * @version		$Id: 3.0.14 Olympus 2010-09-28 rammstein4o $
 * @copyright  2007 - 2010 jVitals
 * @license   GPLv3 Open Source
 * @link       http://jvitals.com
 * @since      File available since initial release
 *}
{script src='js/attachment.js'}
<script type="text/javascript">
<!--
var agora_preview_url = '{url task=post page=reply action=preview id=$topic_id format=raw}';
{literal}
function agora_preview() {

	var preview_data = {
		req_message: ($$('textarea[name=req_message]').getValue()).toString(),
		hide_smilies: ($$('input[name=hide_smilies]').getValue()).toString()
	};

	if (!$$('input[name=hide_smilies]').getProperty('checked')) {
		preview_data.hide_smilies = 0;
	}

	new Ajax(agora_preview_url, {
			method: 'post',
			data: preview_data,
			onFailure: function(){},
			onComplete: function(inResponse) {
				var box = SqueezeBox.initialize();
				box.assignOptions();
				box.setContent('string',inResponse);
			}
	}).request();
}
function populate_hidden() {
	if($('upload').value) {
		var req = ($$('textarea[name=req_message]').getValue()).toString();
		document.getElementById('msg_hidden').value = escape(req);
		document.uploadform.submit();
	} else {
		alert('Please choose a file');
	}
}
{/literal}
//-->
</script>

<div class="ag_rightend">
	<h2 class="ag_headerbar"><span class="ag_middle">##POST REPLY##</span></h2>
</div>

<div class="ag_outerwrap">
	<form id="post" method="post" name="post" action="{url task=post page=reply id=$topic_id}">
		{if $agora_user.id eq '0'}
		<fieldset class="ag_inform">
			<legend class="ag_color">##User information##</legend>
			<label>
				##Name##
				<input name="topic_username" class="required" type="text" value="{if $topic_username}{$topic_username|escape}{/if}" />
			</label>
			<label>
				##Email##
				<input name="guest_email" class="email required" type="text" value="{if $topic_email}{$topic_email|escape}{/if}" />
			</label>
		</fieldset>
		{/if}
		<fieldset class="ag_inform">
			<legend class="ag_color">##Write message legend##</legend>
			{include file=agora:post/post.tpl}
		</fieldset>
		<fieldset class="ag_inform">
			<legend class="ag_color">##Options##</legend>
			<div class="ag_infldset">
				<label>
					<input type="checkbox" name="hide_smilies" value="1" />##Hide smilies##
				</label>
				<br />
				<label>
					<input type="checkbox" name="merge" value="1" checked="checked" />##Merge posts##
				</label>
				<br />
				<label>
					<input type="checkbox" name="subscribe" value="1" {if $agora_config.o_auto_subscriptions and $agora_user.auto_subscriptions}checked="checked"{/if} />##Subscribe##
				</label>
			</div>
		</fieldset>
		<div class="ag_postbuttons">
			<span>
				<input class="ag_button ag_btn_submit" type="submit" name="submit" value="##Submit##" title="##Submit##" accesskey="s" tabindex="5" />
				<input class="ag_button ag_btn_preview" type="button" name="preview" value="##Preview##" title="##Preview##" accesskey="p" onclick="agora_preview()" tabindex="4" />
				&nbsp;##or##&nbsp;
				<a href="javascript:void(0);" class="ag_btn_goback" title="##Go back##" onclick="javascript:history.go(-1)" tabindex="6">##Go back##</a>
			</span>
		</div>
	</form>
	{if $agora_config.o_allow_attach eq '1' and $agora_config.o_attach_type eq '0' and $agora_user.id}
	<form id="uploadform" name="uploadform" method="post" action="{url task=upload action=add redir=self}" onsubmit="populate_hidden();return false;" enctype="multipart/form-data">	
		<fieldset class="ag_inform">
			<legend class="ag_color">##Attachment##</legend>
			<div class="ag_infldset">
				<input type="file" id="upload" name="upload" style="width:99%;" />
				<input class="ag_button ag_btn_submit" type="submit" name="sbm" value="##Upload##" title="##Upload##" />
				<input type="hidden" name="msg_hidden" id="msg_hidden" value="" />
			</div>
		</fieldset>
	</form>
	{/if}
	<script type="text/javascript">
	<!--
	{literal}
	window.addEvent('domready', function(){
		var myFormValidation = new Validate('post',{
			errorClass: 'red',
			label: '##Please wait##'
		});
	});
	{/literal}
	//-->
	</script>
</div>
<div class="ag_forum_separator"></div>

{foreach name=post_loop  from=$posts item=post}
{include file=agora:include/post_row.tpl post_num=$post.post_number post_num_on_page=$smarty.foreach.post_loop.iteration}
{/foreach}

<div class="ag_postlinksBottom">
	<div class="ag_pagelink">
		{include file=agora:include/paginate.tpl}
	</div>
</div>
<div class="ag_bcrumbs">
	{include file=agora:include/bcrumbs.tpl}
</div>
<div class="ag_clearer"></div>

<script type="text/javascript">
<!--
{if isset($smarty.session.form_hidden)}
	document.getElementById('req_message').innerHTML = unescape('{$smarty.session.form_hidden.message}');
	{php} unset($_SESSION['form_hidden']); {/php}
{/if}
{if isset($smarty.session.add_attachment)}
	image('{$smarty.session.add_attachment.path}','{$smarty.session.add_attachment.name}','{$smarty.session.add_attachment.mini}','{$smarty.session.add_attachment.width}','{$smarty.session.add_attachment.height}');
	{php} unset($_SESSION['add_attachment']); {/php}
{/if}
//-->
</script>